package servlet;

import pojo.Category;
import pojo.Publisher;
import service.CategoryService;
import service.CategoryServiceImpl;
import service.PublisherService;
import service.PublisherServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * Created by Tiler on 2020/11/4
 */
public class GotoAddBook extends HttpServlet {
    private PublisherService publisherService = new PublisherServiceImpl();

    private CategoryService categoryService = new CategoryServiceImpl();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        List<Publisher> publishers = publisherService.getAllPublishers();
        List<Category> categories = categoryService.getAllCategories();

        req.setAttribute("publishers", publishers);
        req.setAttribute("categories", categories);

        req.getRequestDispatcher("add_book.jsp").forward(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
